import tensorflow as tf

state = tf.Variable(0,name = 'counter')

#常量
one = tf.constant(1)

#定义加法步骤(只是定义，所有运算要到session才开始）
new_value = tf.add(state,one)

#将State更新成new_value，把new_value值赋给state,让state初始化
update = tf.assign(state,new_value)

#如果定义了Variable,就一定要initialize
init = tf.global_variables_initializer()

#使用Session()
with tf.Session() as sess:
    sess.run(init)
    for i in range(6):
        sess.run(update)
        print(sess.run(state))